import { CoolController, BaseController } from '@cool-midway/core';
import { OrderGoodsEntity } from '../../entity/goods';
import { OrderGoodsService } from '../../service/goods';
import { Body, Inject, Post, Get } from '@midwayjs/core';

/**
 * 订单商品
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: OrderGoodsEntity,
  service: OrderGoodsService,
  pageQueryOp: {
    keyWordLikeFields: ['a.goodsName'],
    fieldEq: ['a.orderId'],
    // where: [['a.relatedGoodsId IS NULL']],
  },
})
export class AdminOrderGoodsController extends BaseController {
  @Inject()
  orderGoodsService: OrderGoodsService;
  // 添加商品
  @Post('/addGoods')
  async addGoods(@Body() body: {}) {
    const res = await this.orderGoodsService.addGoods(body);
    return this.ok(res);
  }
  @Post('/getGoodsDetail')
  async getGoodsDetail(@Body() body: {}) {
    const res = await this.orderGoodsService.getGoodsDetail(body);
    return this.ok(res);
  }
  // 查找配镜限制
  @Post('/getGoodsLensDataByIds')
  async getGoodsLensDataByIds(@Body() body: { goodsIds: number }) {
    const res = await this.orderGoodsService.getGoodsLensDataByIds(body);
    return this.ok(res);
  }
}
